<template>
  <div id="MyTask">
    <el-table
      border
      stripe
      :data="taskData"
    >
      <el-table-column label="团队名称" prop="teamName" align="center"></el-table-column>
      <el-table-column label="任务名称" prop="schedulingName" align="center"></el-table-column>
      <el-table-column label="开始时间" prop="startDateTime" align="center"></el-table-column>
      <el-table-column label="结束时间" prop="endDateTime" align="center"></el-table-column>
      <el-table-column label="操作" align="center">
        <template v-slot="{row}">
          <el-button type="primary" @click="clockIn(row)">打卡</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { listUserScheduling } from '@/api/scheduling'
import { clockIn as doClockIn } from '@/api/clock'

export default {
  name: 'MyTask',
  data() {
    return {
      taskData: []
    }
  },
  mounted() {
    this.getTaskData()
  },
  methods: {
    getTaskData() {
      listUserScheduling(this.$store.getters.username).then(res => {
        this.taskData = res.data.list
      })
    },
    clockIn(row) {
      console.log(row)
      doClockIn({
        schedulingId: row.id
      }).then(res => {
        if (res.resultCode === 200) {
          this.$message.success('打卡成功');
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">

</style>
